/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.appleframework.server;

import org.appleframework.Apple;
import org.appleframework.Logger;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.simpleframework.http.core.Container;
import org.simpleframework.transport.connect.Connection;
import org.simpleframework.transport.connect.SocketConnection;

/**
 *
 * @author zhujg
 */
public class Server {

  private int port = 0; //服务端口
  public Server(){
    port = Integer.parseInt(Apple.configuration.getProperty("apple.port", "9000"));
    try {
      Container container = new HttpHandle();
      Connection connection = new SocketConnection(container);
      SocketAddress address = new InetSocketAddress(port);
      connection.connect(address);
      Logger.debug("服务已开启:%s",port);
    } catch (IOException ex) {
      Logger.debug("启动服务器出错:",ex);
      System.exit(0);
    }
  }

  public static void main(String args[]){
    File root = new File("C:\\usr\\work\\projects\\java\\appleframework");
    Apple.init(root);
    new Server();
  }
  
}
